﻿namespace EyeOpen.Toolbar.Windows
{
	using System;
	using System.Collections.Generic;
	using System.Windows.Forms;

	public partial class MainForm : Form
	{
		public MainForm()
		{
			InitializeComponent();

			var buttons = GetButtonList();

			foreach (var toolStripButton in buttons)
			{
				toolStrip1.Items.Add(toolStripButton);
			}
		}

		private void Edit()
		{
			MessageBox.Show("Edit");
		}

		private void Save()
		{
			MessageBox.Show("Save");
		}

		private IEnumerable<ToolStripButton> GetButtonList()
		{
			yield return 
				this.CreateButton("Edit", this.Edit);

			yield return
				this.CreateButton("Save", this.Save);
		}

		private ToolStripButton CreateButton(string text, Action action)
		{
			var button =
				new ToolStripButton(text);

			button.Click += (s, e) => action();

			return
				button;
		}
	}
}